Ext.define('AmpleHarvest.objects.tags.cPanel',
		{
			extend			: 'Ext.panel.Panel',
			alias			: 'widget.ampleharvest-objects-tags-cpanel',
			requires		:
			[
				'AmpleHarvest.objects.tags.cToolbar'
			],
			iconCls			: 'toolbar-article-navigation-tags',
			title			: 'Tags',
			collapsible		: true,
			statics			:
			{
				C_STR_EVENT_CHANGE_GROUP	: "dochangegroup"
			},
			initComponent	: function()
			{
				var obj_This = this;

				this.m_obj_Store = Ext
						.create("AmpleHarvest.DATA.Store.security.cTagging");

				this.addEvents(this.self.C_STR_EVENT_CHANGE_GROUP);
				this.m_obj_Toolbar = Ext
						.create('AmpleHarvest.objects.tags.cToolbar');
				this.tbar = this.m_obj_Toolbar;

				this.m_obj_Groups = Ext
						.create(
								'AmpleHarvest.objects.tags.group.cPanel',
								{}
						);

				this.m_obj_Grid = Ext.create(
						'AmpleHarvest.objects.tags.cGrid', {}
				);
				this.callParent();

				this.add(this.m_obj_Groups);
				this.add(this.m_obj_Grid);

				// Add Events
				this.on(this.self.C_STR_EVENT_CHANGE_GROUP, this.onChangeGroup,
						obj_This
				);
			},
			onChangeGroup	: function(str_GroupId, str_OldGroupID)
			{
				this.m_obj_Toolbar.disable_Add(true);
				this.m_obj_Toolbar.disable_Remove(true);
				if (str_GroupId == 'all')
				{
					return;
				}
				this.m_obj_Store.set_ExtraParams(
						{
							groupId	: str_GroupId
						});
				this.m_obj_Store.load(
						{
							scope		: this,
							callback	: function(obj_Records, strOperation,
									bool_Success)
							{
								if (bool_Success)
								{
									if (obj_Records[0].raw.tagging_add)
									{
										this.m_obj_Toolbar.disable_Add(false);
									}
									if (obj_Records[0].raw.tagging_remove)
									{
										this.m_obj_Toolbar
												.disable_Remove(false);
									}
								}
							}
						});

			},

			hasData			: function()
			{

				return true;
			}
		}
);